/*
package com.kwq.shixi.Exception;




import com.kwq.shixi.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;


*/
/*
* 描述：  处理统一异常的handler
* *//*

@ControllerAdvice
public class GlobalExpectionHandler {
    private final Logger log= LoggerFactory.getLogger(GlobalExpectionHandler.class);
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result handleException(Exception e){
        System.out.println("有异常eeeee");
        log.error("Default Exception:",e);
        return new Result(ImoocMallExceptionEnum.NO_ENUM);

    }
    @ExceptionHandler(ImoocMallException.class)
    @ResponseBody
    public Result handleImoocMallException(ImoocMallException e) {
        log.error("ImoocMallException: ", e);
        System.out.println(e.getCode());
        System.out.println(e.getMessage());
        return new Result(e.getCode(), e.getMessage());
    }

    @ExceptionHandler(MethodArgumentNotValidException.class)
    @ResponseBody
    public Result handleMethodArgumentNotValidException(
            MethodArgumentNotValidException e) {
        log.error("MethodArgumentNotValidException: ", e);
        return handleBindingResult(e.getBindingResult());
    }

    private Result handleBindingResult(BindingResult result) {
        //把异常处理为对外暴露的提示
        List<String> list = new ArrayList<>();
        if (result.hasErrors()) {
            List<ObjectError> allErrors = result.getAllErrors();
            for (ObjectError objectError : allErrors) {
                String message = objectError.getDefaultMessage();
                list.add(message);
            }
        }
        if (list.size() == 0) {
           */
/* return ApiRestResponse.error(ImoocMallExceptionEnum.REQUEST_PARAM_ERROR);*//*

            return new Result(ImoocMallExceptionEnum.CREATE_FAILED);
        }
       */
/* return ApiRestResponse
                .error(ImoocMallExceptionEnum.REQUEST_PARAM_ERROR.getCode(), list.toString());*//*

        return new Result(ImoocMallExceptionEnum.CART_EMPTY,list);
    }
}
*/
